<template>
  <div class="app-hamburger" @click="toggleSiderBar">
    <MenuUnfoldOutlined v-if="sidebarCollapsed" />
    <MenuFoldOutlined v-else />
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons-vue'
import { useStore } from 'vuex'

export default defineComponent({
  name: 'Hamburger',
  components: {
    MenuUnfoldOutlined,
    MenuFoldOutlined,
  },

  setup() {
    const store = useStore()
    const sidebarCollapsed = computed(() => store.state.app.sidebarCollapsed)

    const toggleSiderBar = () => {
      store.commit('app/TOGGLE_COLLAPSED')
    }

    return {
      sidebarCollapsed,
      toggleSiderBar,
    }
  },

  methods: {
    // toggleSiderBar() {
    //   alert(1)
    // }
  }
})
</script>

<style lang="scss">
.app-hamburger{
  display: inline-block;
  font-size: 20px;
  line-height: 64px;
  cursor: pointer;
  margin-left: 20px;
}
</style>
